using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Psi.Domain;

namespace Psi.EntityFrameworkCore.DbMigrations.Configurations
{
    /// <summary>
    /// 映射配置
    /// </summary>
    public class CatelogConfiguration : MasterEntityConfiguration<Catelog>
    {
        protected override void Configures(EntityTypeBuilder<Catelog> builder)
        {
            //基类配置
            base.Configures(builder);

            builder.Property(x => x.Name).HasColumnName("name").HasComment("类别名称").HasMaxLength(50);
            ////图标
            //builder.Property(x => x.Icon).HasColumnName("icon").HasComment("图标").HasMaxLength(50);
            ////排序
            //builder.Property(x => x.Sort).HasColumnName("sort").HasComment("排序");
            ////代码
            //builder.Property(x => x.Code).HasColumnName("code").HasComment("代码");
            ////状态0禁用1启用
            //builder.Property(x => x.Status).HasColumnName("status").HasComment("状态0禁用1启用");

            ////索引
            //builder.HasIndex(x => new { x.CourtId, x.MiddleId, x.Title });

            //ToTable
            builder.ToTable("catelog");
        }


        //public class CatelogConfiguration : EntityConfigurationBase<Catelog>
        //{
        //    /// <summary>
        //    /// 重写以实现实体类型各个属性的数据库配置
        //    /// </summary>
        //    /// <param name="builder">实体类型创建器</param>
        //    public override void Configure(EntityTypeBuilder<Catelog> builder)
        //    {
        //        //builder.HasIndex(m => new { m.EntityId, m.RoleId, m.Operation }).HasName("EntityRoleIndex").IsUnique();

        //        //builder.HasOne<EntityInfo>(er => er.EntityInfo).WithMany().HasForeignKey(m => m.EntityId);
        //        //builder.HasOne<Role>(er => er.Role).WithMany().HasForeignKey(m => m.RoleId);

        //        //EntityConfigurationAppend(builder);
        //    }

        //    ///// <summary>
        //    ///// 额外的数据映射
        //    ///// </summary>
        //    //partial void EntityConfigurationAppend(EntityTypeBuilder<Catelog> builder);
        //}
    }
}
